<?php
/**
 * Created by PhpStorm.
 * User: zhoujinda
 * Date: 2015/12/18
 * Time: 15:10
 */

namespace Test\Controller;


use Common\Api\BoyeServiceApi;

class TestPurifierController extends TestController
{
    public function index(){
        $this->display();
    }

    public function add(){
        if(IS_POST){
            $data = array(
                'mobile' => I('post.mobile',0),
                'ddid' => I('post.ddid',''),
                'device_model' => I('post.device_model',''),
                'name' => I('post.name',''),
                'install_time' => I('post.install_time',''),
                'provinceid' => I('post.provinceid',''),
                'cityid' => I('post.cityid',''),
                'areaid' => I('post.areaid',''),
                'detailinfo'=>I('post.detailinfo',''),
                'api_ver'=>100,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_Purifier_add',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,True);

            $this->parseResult($result);

        }
        $this->display();
    }

    public function query(){
        if(IS_POST){
            $data = array(
                'uid' => I('post.uid',0),
                'api_ver'=>100,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_Purifier_query',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,True);

            $this->parseResult($result);
        }
        $this->display();
    }

    public function delete(){
        if(IS_POST){
            $data = array(
                'id' => I('post.id',0),
                'api_ver'=>100,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_Purifier_delete',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,True);

            $this->parseResult($result);
        }
        $this->display();
    }

    private function parseResult($result){
        echo "解密后数据：";
        dump($result);
    }

}